package net.tavion.angelboot.common.vo;



import net.tavion.angelboot.common.enums.SystemCode;
import net.tavion.angelboot.common.head.RequestHeadDataHolder;

import java.io.Serializable;

/**
 * https://blog.csdn.net/autfish/article/details/90405679
 * @param <T>
 */
public class GenericResponse<T> implements Serializable {

    private String code;
    private String message;
    private String requestId;
    private T data;


    public GenericResponse() {
        this(SystemCode.SUCCESS.getCode(),SystemCode.SUCCESS.getMessage(), RequestHeadDataHolder.getRequestHeadData().getRequestId(),null);
    }


    public GenericResponse(T data) {
        this(SystemCode.SUCCESS.getCode(),SystemCode.SUCCESS.getMessage(),RequestHeadDataHolder.getRequestHeadData().getRequestId(), data);
    }

    public GenericResponse(String code, String message) {
        this(code,message, RequestHeadDataHolder.getRequestHeadData().getRequestId(), null);
    }

    public GenericResponse(SystemCode code) {
        this.code = code.getCode();
        this.message = code.getMessage();
        this.requestId = RequestHeadDataHolder.getRequestHeadData().getRequestId();
        this.data = null;
    }

    public GenericResponse(String code, String message,T data) {
        this(code,message, RequestHeadDataHolder.getRequestHeadData().getRequestId(), data);
    }

    public GenericResponse(String code, String message, String requestId, T data) {
        this.code = code;
        this.message = message;
        this.requestId = requestId;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

}
